<?php



namespace App\Http\Requests\Company;

use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;

class ConquerRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:120',

        ];
    }

    public function messages()
    {
        return [
            'title.required' => __('请输入活动的标题'),
            'expired_days.required' => __('请输入活动有效期'),
            'start_at.required' => __('请输入活动的开始日期'),
            'unit.required' => __('请输入活动计量的单位'),
            'measure.required' => __('请输入活动的量度'),
            'thumb.required' => __('请输入活动的封面'),

        ];
    }

    public function filldata()
    {

        $user = Auth::user();
        return [
            'user_id'=>(int)$user['app_id'],
            'status'=>(int)$this->input('status',-1),
            'company_id' =>(int)$user['login_company_id'],
            'title' =>(string) $this->input('title', ''),
            'thumb' =>(string) $this->input('thumb', ''),
            'short_description' =>(string) $this->input('short_description', ''),
            'expired_days' =>(int) $this->input('expired_days', 1),
            'start_at' => Carbon::parse($this->input('start_at'))->toDateTimeLocalString(),
            'unit' => (string)$this->input('unit', ''),
            'measure'=>(string)$this->input('measure',''),


        ];
    }
}
